package Text1;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
public class Main{
    public static void main(String[] args) throws IOException {
        BufferedReader Reader = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter Writer = new BufferedWriter(new OutputStreamWriter(System.out));
        int n=Integer.parseInt(Reader.readLine());
        char[] p = new char[n + 1];
        int[] ne = new int[n + 1];
        String str1=Reader.readLine();
        for (int i = 1; i <=n; i++) {
            p[i]=str1.charAt(i-1);
        }
        int m=Integer.parseInt(Reader.readLine());
        char[] s = new char[m + 1];
        String str2=Reader.readLine();
        for (int i = 1; i <=m; i++) {
            s[i]=str2.charAt(i-1);
        }
        for (int i = 2,j=0; i <=n ; i++) {
            while(j>0&&p[i]!=p[j+1]){
                j=ne[j];
            }
            if(p[i]==p[j+1]){
                j++;
            }
            ne[i]=j;
        }
        for (int i = 1,j=0; i <=m ; i++) {
            while(j>0&&p[i]!=p[j+1]){
                j=ne[j];
            }
            if(s[i]==p[j+1]){
                j++;
            }
            if(j==n){
                Writer.write(i-n+" ");
                j=ne[j];
            }
        }
        Writer.flush();
        Writer.close();
        Reader.close();
    }
}

